<?php

/**
 * The Filter class, filters are actions that can be done on the image
 * by the drawer. Filters can be nested to do more advanced things.
 *
 * @version $Revision v1.00$
 * @author Bryan Spirit & Mark Kazemier
 */
abstract class Filter
{
    private $m_oFilter;
    
    /**
     * Constructs a new filter. The nested filter is optional.
     *
     * @param Filter An optional nested filter
     */
    public function __construct(Filter $oFilter = null)
    {
        if(!$oFilter == null)
            $this->setFilter($oFilter);
    }
    
    /**
     * Method to set a nested filter
     *
     * @param Filter The nested filter
     */
    public function setFilter(Filter $oFilter)
    {
        $this->m_oFilter = $oFilter;
    }
    
	// TODO: Better name, it is now the PHP 4 constructor

    /**
     * Method that filters the given image.
     *
     * @throws FilterDrawException When filter fails
     * @param Image Image on which this filter has to filter
     */
    public function filter(Image $oImage)
    {
        if($this->m_oFilter != null)
            $this->m_oFilter->filter($oImage);
    }
}
